<?php
	$cateModel = new \Common\Model\Category;
//	顶级分类
	$cateData = $cateModel->get();
	$cateData = Data::channelLevel($cateData, $pid = 0, $html = "&nbsp;", $fieldPri = 'cid', $fieldPid = 'pid', $level = 1);
	View::with('cateData',$cateData);
//	获得购物车中的数据
	/*session_unset();
	session_destroy();*/
	$cartData = Cart::getAllData();
	View::with('cartData',$cartData);
//	p($cartData);
?>
<script src="Public/Home/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
	var cart = "<?php echo U('Cart/getCart')?>"
</script>
<!--头部公用模板-->
<div id="header">
	<!--顶部banner-->
	<div class="top_banner">
		<a class="block" href="#"></a>
	</div>
	<!--登陆注册导航栏-->
	<div class="top_nav">
		<div class="top_nav_con">
			<!--登陆注册导航左侧-->
			<ul class="top_nav_left fl">
				<li class="fl">
					<a class="block clicked" href="<?php echo U('Index/index')?>">时尚商城</a>
				</li>
				<li class="fl seoul">
					<a class="block" href="">
						<span class="en">Seoul Station</span>
						<span class="zn">首 尔 站</span>
					</a>
				</li>
				<li class="phone fl">
					<a class="block" href="">
						<i class=""></i>
						手机优购
						<i class="tip"></i>
					</a>
					<div class="phone_con">
			          <p class="clearfix">
			            <span class="fl qr_code">
			            </span>
			            <span class="fl ml10">
			                <a class="btn_app_store btn" href="#" target="_blank">AppStore</a>
			                <a class="btn_android_store btn" href="#" target="_blank">Android</a>
			            </span>
			          </p>
			          <p class="fl qr_code_tip">下载安装 <strong>优购客户端</strong></p>
			        </div>
				</li>
			</ul>
			<!--登陆注册导航右侧-->
			<div class="top_nav_right fr">
				<div class="about_user fl">
					<?php if(!isset($_SESSION['uid'])){?>
                
					<div class="no_login">
						<div class="login fl">
							<a href="<?php echo U('Login/index')?>">登陆</a>
						</div>
						<div class="register fl">
							<a href="<?php echo U('Reg/index')?>">注册</a>
						</div>
					</div>
					<!--登陆后-->
					<?php }else{?>
					<div class="ok_login">
						<div class="username fl">
							您好！<span><?php echo $_SESSION['username']?></span>
						</div>
						<div class="quit fl">
							<a href="<?php echo U('Login/quit')?>">退出</a>
						</div>
					</div>
					
               <?php }?>
				</div>
				
				<div class="my_yg link_box hover">
					<a href="<?php echo U('UserCenter/index')?>" class="my">我的优购</a>
					<ul class="info_con">
						<li><a href="#">我的收藏</a></li>
					</ul>
				</div>
				
				<div class="my_order link_box">
					<a href="#">我的订单</a>
				</div>
				
				<div class="notice link_box">
					<span class="notice_text">公告</span>
					<ul class="notice_con">
						<li><a href="#">公告1</a></li>
						<li><a href="#">公告2</a></li>
						<li><a href="#">公告3</a></li>
						<li><a href="#">公告4</a></li>
						<li><a href="#">公告5</a></li>
					</ul>
				</div>
				
				<div class="more link_box">
					<span class="more_text">更多</span>
					<ul class="more_con">
						<li><a href="#">收藏优购</a></li>
						<li><a href="#">帮助</a></li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	
		
		
	<?php if('List'!='Login' and 'List'!='Reg' and 'List'!='Order'){?>
                
	<!--LOGO,搜索，购物车-->
	<div class="site_header">
		<!--logo区域-->
		<div class="logo fl">
			<a class="block" href="<?php echo U('Index/index')?>"></a>
		</div>
		<!--搜索区域-->
		<form class="search fl" action="" method="post">
			<input type="text" name="keyword" class="search_box fl" id="keyword" placeholder="请输入搜索关键词" />
			<input type="submit" class="search_btn fl" value="搜索"/>
		</form>
		<!--购物车-->
		<div class="mycart_nav fr">
			<a href="<?php echo U('Cart/index')?>">
		    <div class="mycart_btn">
		        <div class="zs_left fl"></div>
		        <div class="zs_center fl">
		        	<div class="tip_left fl"></div>
		        	<div id="paymoney" class="text fl">购物车(<span id="pordcount"><?php if($cartData['total_rows']){?>
                <?php echo $cartData['total_rows']?><?php }else{?>0
               <?php }?></span>)件</div>
		        	<div class="tip_right fl"></div>
		        </div>
		        <div class="zs_right fl"></div>
		    </div>
		    </a>
		    
		    <div id="shoppingcartContainer">
		    	
		    </div>
		    
    	</div>
		<!--公司名称-->
		<div class="company_name fr">
		香港上市公司百丽国际旗下购物网站
		</div>
		<!--热搜关键词-->
		<div class="search_hot">
			<a href="">2件￥199</a>
			|
			<a href="">跑步鞋</a>
			|
		</div>
	</div>
	<!--导航看-->
	<div class="category_nav">
		<div class="nav">
			<!--水平导航-->
			<div class="x_nav fr">
				<ul class="x_nav_list fl">
					<?php foreach ($cateData as $v){?>
					<li><a href="<?php echo U('List/index',array('cid'=>$v['cid']))?>"><?php echo $v['cname']?></a></li>
					<?php }?>
				</ul>
				<ul class="x_nav_list fr">
					<li class="fr"><a href="">潮流馆</a></li>
					<li class="fr"><a href="">闪团</a></li>
					<li class="fr"><a href="">秒杀</a></li>
					<li class="fr"><a href="">会员中心</a></li>
				</ul>
			</div>
			<!--垂直导航-->
			<div class="y_nav fl">
				<div class="y_nav_all">
					<a href="<?php echo U('List/index')?>">全部商品分类</a>
				</div>
				<!--垂直分类-->
				<div class='y_nav_list <?php if('List'!='Index'){?>
                no_index
               <?php }?>'>
					<ul class="y_nav_all_list">
						
						
						
						<?php foreach ($cateData as $v){?>
						<li>
							<div class="nav_title">
								<i class="iconfont">&#xe603;</i>
								<h3>
									<a href="<?php echo U('List/index',array('cid'=>$v['cid']))?>"><?php echo $v['cname']?></a>
								</h3>
							</div>
							<div class="nav_title_son">
								        <?php
        if (empty($v['_data'])) 
        {
            echo '';
        } 
        else 
        {
            //初始化
            $first=$last=$total=$index=$id=0;
            $hd['list']['vv']['first']=&$first;
            $hd['list']['vv']['last']=&$last;
            $hd['list']['vv']['total']=&$total;
            $hd['list']['vv']['index']=&$index;
            foreach ($v['_data'] as $vv) 
            {
                //开始值
                if ($id<0)
                {
                    $id++;
                    continue;
                }
                //步长
                if($id%1!=0)
                {   
                    $id++;
                    continue;
                }
                //显示条数
                if($index>=4)
                {
                    break;
                }
                //第几个值
                $index+=1;
                //第1个值
                $first=($id == 0);
                //最后一个值
                $last=($index == 4);
                //增加数
                $id+=1;
            ?>
								<a href="<?php echo U('List/index',array('cid'=>$vv['cid']))?>"><?php echo $vv['cname']?></a>
								<?php }
            //总数
            $total=$index;
        }?>
							</div>
							<div class="nav_menu">
								<?php foreach ($v['_data'] as $vv){?>
								<div class="category">
									<div class="category_title">
										<a href="<?php echo U('List/index',array('cid'=>$vv['cid']))?>">
											<?php echo $vv['cname']?>
										</a>
									</div>
									<div class="category_ul">
										        <?php
        if (empty($vv['_data'])) 
        {
            echo '';
        } 
        else 
        {
            //初始化
            $first=$last=$total=$index=$id=0;
            $hd['list']['vvv']['first']=&$first;
            $hd['list']['vvv']['last']=&$last;
            $hd['list']['vvv']['total']=&$total;
            $hd['list']['vvv']['index']=&$index;
            foreach ($vv['_data'] as $vvv) 
            {
                //开始值
                if ($id<0)
                {
                    $id++;
                    continue;
                }
                //步长
                if($id%1!=0)
                {   
                    $id++;
                    continue;
                }
                //显示条数
                if($index>=16)
                {
                    break;
                }
                //第几个值
                $index+=1;
                //第1个值
                $first=($id == 0);
                //最后一个值
                $last=($index == 16);
                //增加数
                $id+=1;
            ?>
										<a href="<?php echo U('List/index',array('cid'=>$vvv['cid']))?>"><?php echo $vvv['cname']?></a>
										<?php }
            //总数
            $total=$index;
        }?>
									</div>
								</div>
								<?php }?>
							</div>
						</li>
						<?php }?>
					</ul>
				</div>
			</div>
		</div>
	</div>
	
               <?php }?>
</div>

<script type="text/javascript">
	$(function(){
	$('.mycart_nav').hover(function(){
		$('#shoppingcartContainer').css({display:'block'});
		$.ajax({
			type:"post",
			url:cart,
			data:{status:1},
			dataType:'json',
			success:function(data){
				var str = '';
				var num = 0;
				$.each(data, function(k,v) {
					str +='<div class="goods"><table><tr style="border-bottom: 1px dotted #CCCCCC;"><td style="text-align: center;" width="60">';
		    		str +='<a href="#"><img style="width: 40px;height: 40px;" src="'+v.options.listpic+'"/></a></td><td width="240" style="padding-left: 6px;"><p>';
		    		str +='<a href="">'+v.name+'</a></p><p>';
		    		str +='颜色：<span>'+v.options.color+'</span>';
		    		str +='&nbsp;&nbsp;&nbsp;&nbsp;'
		    		str +='尺寸：<span>'+v.options.size+'</span></p></td><td width="60">';
		    		str +='<span>￥'+v.total+'</span></td><td class="change_num" width="60">';
					str +='数量：'+v.num+'</td></tr></table></div>';
		    		num++;
				});
				str +='<div class="count">';
				str +='<p class="fl">共<span>' + num +'</span>件商品</p>';
		    	str +='<a class="btn fr" href="<?php echo U('Cart/index')?>">去购物车结算</a></div>';
		    		
				
				$('#shoppingcartContainer').html(str);
			}
		});
	},function(){
		$('#shoppingcartContainer').css({display:'none'});
	})
})

</script>













